﻿Imports System.Text
Namespace DataMaster
    Public Class clsMSTARTICLERow
        Inherits ADODBU.RowClass
        Private mVar_ARTCOD As System.Int32
        Private mVar_ARTCEXT As System.String
        Private mVar_ARTDESC As System.String
        Private mVar_ARTMRC As System.Int32
        Private mVar_ARTTYPE As System.Int32
        Private mVar_ARTSTAT As System.Int32
        Private mVar_ARTNOTE As System.String
        Private mVar_ARTDCRE As System.DateTime
        Private mVar_ARTDMAJ As System.DateTime
        Private mVar_ARTUTIL As System.String
        Private mVar_ARTPROG As System.String
        Private mVar_DirtyARTCOD As Boolean = False
        Private mVar_DirtyARTCEXT As Boolean = False
        Private mVar_DirtyARTDESC As Boolean = False
        Private mVar_DirtyARTMRC As Boolean = False
        Private mVar_DirtyARTTYPE As Boolean = False
        Private mVar_DirtyARTSTAT As Boolean = False
        Private mVar_DirtyARTNOTE As Boolean = False
        Private mVar_DirtyARTDCRE As Boolean = False
        Private mVar_DirtyARTDMAJ As Boolean = False
        Private mVar_DirtyARTUTIL As Boolean = False
        Private mVar_DirtyARTPROG As Boolean = False
        Private mIsOnInit As Boolean
        Public DataSource As ADODBU.Recordset
        Public RowOrigin As clsMSTARTICLERow
        ''[------------------------------------------------------------------------]'
        Public Sub New()
            RowOrigin = New clsMSTARTICLERow(True)
        End Sub
        ''[------------------------------------------------------------------------]'
        Friend Sub New(lCut As Boolean)
            '--- untuk memutus loop reference 
        End Sub
        ''[------------------------------------------------------------------------]'
        ''' <summary>
        ''' create new this class from inherited of this class or its self
        ''' </summary>
        ''' <param name="recdataRow"></param>
        ''' <remarks></remarks>
        Public Sub New(ByVal recdataRow As ADODBU.RowClass)
            RowOrigin = New clsMSTARTICLERow(True)
            Me.JoinValue(recdataRow)
        End Sub
        ''[------------------------------------------------------------------------]'
        Public Sub New(recData As ADODBU.Recordset)
            RowOrigin = New clsMSTARTICLERow(True)
            DataSource = recData
            Try
                InitVar(recData.GetCurrentDataRow)
            Catch
            End Try
        End Sub

        ''[------------------------------------------------------------------------]'
        Public Sub New(recdataRow As DataRow)
            RowOrigin = New clsMSTARTICLERow(True)
            InitVar(recdataRow)
        End Sub

#Region "Initialize vars "
        ''[------------------------------------------------------------------------]'
        Private Sub InitVar(Fields As DataRow)
            Try
                mVar_ARTCOD = Fields("ARTCOD")
                RowOrigin.ARTCOD = mVar_ARTCOD
            Catch e As Exception
            End Try
            Try
                mVar_ARTCEXT = Fields("ARTCEXT")
                RowOrigin.ARTCEXT = mVar_ARTCEXT
            Catch e As Exception
            End Try
            Try
                mVar_ARTDESC = Fields("ARTDESC")
                RowOrigin.ARTDESC = mVar_ARTDESC
            Catch e As Exception
            End Try
            Try
                mVar_ARTMRC = Fields("ARTMRC")
                RowOrigin.ARTMRC = mVar_ARTMRC
            Catch e As Exception
            End Try
            Try
                mVar_ARTTYPE = Fields("ARTTYPE")
                RowOrigin.ARTTYPE = mVar_ARTTYPE
            Catch e As Exception
            End Try
            Try
                mVar_ARTSTAT = Fields("ARTSTAT")
                RowOrigin.ARTSTAT = mVar_ARTSTAT
            Catch e As Exception
            End Try
            Try
                mVar_ARTNOTE = Fields("ARTNOTE")
                RowOrigin.ARTNOTE = mVar_ARTNOTE
            Catch e As Exception
            End Try
            Try
                mVar_ARTDCRE = Fields("ARTDCRE")
                RowOrigin.ARTDCRE = mVar_ARTDCRE
            Catch e As Exception
            End Try
            Try
                mVar_ARTDMAJ = Fields("ARTDMAJ")
                RowOrigin.ARTDMAJ = mVar_ARTDMAJ
            Catch e As Exception
            End Try
            Try
                mVar_ARTUTIL = Fields("ARTUTIL")
                RowOrigin.ARTUTIL = mVar_ARTUTIL
            Catch e As Exception
            End Try
            Try
                mVar_ARTPROG = Fields("ARTPROG")
                RowOrigin.ARTPROG = mVar_ARTPROG
            Catch e As Exception
            End Try
        End Sub


#End Region
        ''[------------------------------------------------------------------------]'
#Region "Properties"
        Public Property ARTCOD As System.Int32
            Get
                Return mVar_ARTCOD
            End Get
            Set(ByVal Value As System.Int32)
                mVar_ARTCOD = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTCOD"))
                If Not mIsOnInit Then
                    mVar_DirtyARTCOD = True
                End If
            End Set
        End Property
        Public Property ARTCEXT As System.String
            Get
                Return mVar_ARTCEXT
            End Get
            Set(ByVal Value As System.String)
                mVar_ARTCEXT = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTCEXT"))
                If Not mIsOnInit Then
                    mVar_DirtyARTCEXT = True
                End If
            End Set
        End Property
        Public Property ARTDESC As System.String
            Get
                Return mVar_ARTDESC
            End Get
            Set(ByVal Value As System.String)
                mVar_ARTDESC = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTDESC"))
                If Not mIsOnInit Then
                    mVar_DirtyARTDESC = True
                End If
            End Set
        End Property
        Public Property ARTMRC As System.Int32
            Get
                Return mVar_ARTMRC
            End Get
            Set(ByVal Value As System.Int32)
                mVar_ARTMRC = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTMRC"))
                If Not mIsOnInit Then
                    mVar_DirtyARTMRC = True
                End If
            End Set
        End Property
        Public Property ARTTYPE As System.Int32
            Get
                Return mVar_ARTTYPE
            End Get
            Set(ByVal Value As System.Int32)
                mVar_ARTTYPE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTTYPE"))
                If Not mIsOnInit Then
                    mVar_DirtyARTTYPE = True
                End If
            End Set
        End Property
        Public Property ARTSTAT As System.Int32
            Get
                Return mVar_ARTSTAT
            End Get
            Set(ByVal Value As System.Int32)
                mVar_ARTSTAT = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTSTAT"))
                If Not mIsOnInit Then
                    mVar_DirtyARTSTAT = True
                End If
            End Set
        End Property
        Public Property ARTNOTE As System.String
            Get
                Return mVar_ARTNOTE
            End Get
            Set(ByVal Value As System.String)
                mVar_ARTNOTE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTNOTE"))
                If Not mIsOnInit Then
                    mVar_DirtyARTNOTE = True
                End If
            End Set
        End Property
        Public Property ARTDCRE As System.DateTime
            Get
                Return mVar_ARTDCRE
            End Get
            Set(ByVal Value As System.DateTime)
                mVar_ARTDCRE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTDCRE"))
                If Not mIsOnInit Then
                    mVar_DirtyARTDCRE = True
                End If
            End Set
        End Property
        Public Property ARTDMAJ As System.DateTime
            Get
                Return mVar_ARTDMAJ
            End Get
            Set(ByVal Value As System.DateTime)
                mVar_ARTDMAJ = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTDMAJ"))
                If Not mIsOnInit Then
                    mVar_DirtyARTDMAJ = True
                End If
            End Set
        End Property
        Public Property ARTUTIL As System.String
            Get
                Return mVar_ARTUTIL
            End Get
            Set(ByVal Value As System.String)
                mVar_ARTUTIL = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTUTIL"))
                If Not mIsOnInit Then
                    mVar_DirtyARTUTIL = True
                End If
            End Set
        End Property
        Public Property ARTPROG As System.String
            Get
                Return mVar_ARTPROG
            End Get
            Set(ByVal Value As System.String)
                mVar_ARTPROG = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("ARTPROG"))
                If Not mIsOnInit Then
                    mVar_DirtyARTPROG = True
                End If
            End Set
        End Property
        Public ReadOnly Property ARTCODIsDirty As Boolean
            Get
                Return mVar_DirtyARTCOD
            End Get
        End Property
        Public ReadOnly Property ARTCEXTIsDirty As Boolean
            Get
                Return mVar_DirtyARTCEXT
            End Get
        End Property
        Public ReadOnly Property ARTDESCIsDirty As Boolean
            Get
                Return mVar_DirtyARTDESC
            End Get
        End Property
        Public ReadOnly Property ARTMRCIsDirty As Boolean
            Get
                Return mVar_DirtyARTMRC
            End Get
        End Property
        Public ReadOnly Property ARTTYPEIsDirty As Boolean
            Get
                Return mVar_DirtyARTTYPE
            End Get
        End Property
        Public ReadOnly Property ARTSTATIsDirty As Boolean
            Get
                Return mVar_DirtyARTSTAT
            End Get
        End Property
        Public ReadOnly Property ARTNOTEIsDirty As Boolean
            Get
                Return mVar_DirtyARTNOTE
            End Get
        End Property
        Public ReadOnly Property ARTDCREIsDirty As Boolean
            Get
                Return mVar_DirtyARTDCRE
            End Get
        End Property
        Public ReadOnly Property ARTDMAJIsDirty As Boolean
            Get
                Return mVar_DirtyARTDMAJ
            End Get
        End Property
        Public ReadOnly Property ARTUTILIsDirty As Boolean
            Get
                Return mVar_DirtyARTUTIL
            End Get
        End Property
        Public ReadOnly Property ARTPROGIsDirty As Boolean
            Get
                Return mVar_DirtyARTPROG
            End Get
        End Property
#End Region
        ''[------------------------------------------------------------------------]'
        Public Function SaveToDataSource() As String
            Dim msgErr As String
            msgErr = ""
            If mVar_DirtyARTCOD Then
                Try
                    DataSource.Fields("ARTCOD") = mVar_ARTCOD
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTCEXT Then
                Try
                    DataSource.Fields("ARTCEXT") = mVar_ARTCEXT
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTDESC Then
                Try
                    DataSource.Fields("ARTDESC") = mVar_ARTDESC
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTMRC Then
                Try
                    DataSource.Fields("ARTMRC") = mVar_ARTMRC
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTTYPE Then
                Try
                    DataSource.Fields("ARTTYPE") = mVar_ARTTYPE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTSTAT Then
                Try
                    DataSource.Fields("ARTSTAT") = mVar_ARTSTAT
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTNOTE Then
                Try
                    DataSource.Fields("ARTNOTE") = mVar_ARTNOTE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTDCRE Then
                Try
                    DataSource.Fields("ARTDCRE") = Format(mVar_ARTDCRE, DataSource.DbConn.DateFormat)
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTDMAJ Then
                Try
                    DataSource.Fields("ARTDMAJ") = Format(mVar_ARTDMAJ, DataSource.DbConn.DateFormat)
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTUTIL Then
                Try
                    DataSource.Fields("ARTUTIL") = mVar_ARTUTIL
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtyARTPROG Then
                Try
                    DataSource.Fields("ARTPROG") = mVar_ARTPROG
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            Return msgErr
        End Function

        ''[------------------------------------------------------------------------]'
        Public Sub ClearDirty()
            mVar_DirtyARTCOD = False
            mVar_DirtyARTCEXT = False
            mVar_DirtyARTDESC = False
            mVar_DirtyARTMRC = False
            mVar_DirtyARTTYPE = False
            mVar_DirtyARTSTAT = False
            mVar_DirtyARTNOTE = False
            mVar_DirtyARTDCRE = False
            mVar_DirtyARTDMAJ = False
            mVar_DirtyARTUTIL = False
            mVar_DirtyARTPROG = False
        End Sub
        ''[------------------------------------------------------------------------]'
        Public Sub SetDirty()
            mVar_DirtyARTCOD = True
            mVar_DirtyARTCEXT = True
            mVar_DirtyARTDESC = True
            mVar_DirtyARTMRC = True
            mVar_DirtyARTTYPE = True
            mVar_DirtyARTSTAT = True
            mVar_DirtyARTNOTE = True
            mVar_DirtyARTDCRE = True
            mVar_DirtyARTDMAJ = True
            mVar_DirtyARTUTIL = True
            mVar_DirtyARTPROG = True
        End Sub

    End Class
End Namespace